package com.freejava.test_thymeleaf.controller;

import com.freejava.test_thymeleaf.entity.Pet;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class PetController {

    // 获取宠物团团的信息
    @GetMapping("/tuantuan")
    public String showTuan(Model model) {
        Pet pet = new Pet();
        pet.setName("泰迪");
        pet.setNickname("团团");
        pet.setAge(2);
        pet.setHairColor("棕色");

        model.addAttribute("pet", pet);

        return "dog_details";
    }

    @GetMapping("/pet/family")
    public String getPetFamily(Model model) {
        List<Pet> family = new ArrayList<>();
        family.add(new Pet("泰迪", "团团", 2,"棕色"));
        family.add(new Pet("中华田园猫", "胖胖", 2,"黑白"));
        family.add(new Pet("银渐层", "怪怪", 1,"黑白"));
        model.addAttribute("pets", family);

        return "pet_family";
    }
}
